<div class="row-content am-cf">
    <div class="row">
        <div class="am-u-sm-12 am-u-md-12 am-u-lg-12">
            <div class="widget am-cf">
                <div class="widget-head am-cf">
                    <div class="widget-title am-cf">已推送模板列表</div>
                </div>
				<div class="tips am-margin-bottom-sm am-u-sm-12">
					<div class="pre-info">
						<p> 注：给用户推送新版本（不推送用户无法获取最新版本），过期版本不建议删除。</p>
					</div>
				</div>
                <div class="widget-body am-fr">
                    <div class="am-u-sm-12 am-u-md-6 am-u-lg-6">
                        <div class="am-form-group">
                            <div class="am-btn-toolbar">
                                <div class="am-btn-group am-btn-group-sm">
                                    <a href="javascript:void(0);" class="hema-add am-btn am-btn-primary am-radius">
                                        <span class="am-icon-plus"></span> 添加
                                    </a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="am-u-sm-12">
                        <table width="100%" class="am-table am-table-hover tpl-table-black">
                            <thead>
                            <tr>
                                <th>模板ID</th>
								<th>模板类型</th>
                                <th>版本号</th>
                                <th>描述</th>
                                <th>发布时间</th>
                                <th>操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            {if !$list->isEmpty()}
                                {foreach $list as $item}
                                <tr>
                                    <td class="am-text-middle"><p>{$item['id']}</p></td>
									<td class="am-text-middle">{$item['template']['name']}</td>
                                    <td class="am-text-middle">{$item['user_version']}</td>
                                    <td class="am-text-middle">{$item['user_desc']}</td>
                                    <td class="am-text-middle">{$item['create_time']}</td>
                                    <td class="am-text-middle">
                                        <div class="tpl-table-black-operation">
                                            <a href="javascript:;" class="hema-edit" data-id="{$item['template_code_id']}">
                                                <i class="am-icon-pencil"></i> 编辑
                                            </a>
                                            <a href="javascript:;" class="hema-del tpl-table-black-operation-del"
                                               data-id="{$item['template_code_id']}">
                                                <i class="am-icon-trash"></i> 删除
                                            </a>
                                        </div>
                                    </td>
                                </tr>
                                {/foreach}
                            {else /}
                                <tr>
                                    <td colspan="6" class="am-text-center">暂无记录</td>
                                </tr>
                            {/if}
                            </tbody>
                        </table>
                    </div>
					<div class="am-u-lg-12 am-cf">
                        <div class="am-fr">{:$list->render()} </div>
                        <div class="am-fr pagination-total am-margin-right">
                            <div class="am-vertical-align-middle">总记录：{:$list->total()}</div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{include file="applet/code/add" /}
{include file="applet/code/edit" /}
<script>
    $(function () {
         //添加
        $('.hema-add').on('click', function () {
            $.get("{:url('applet.code/add')}", function (result) {
				if(result.code == 0){
				    $.show_error(result.msg);
				    return false;
				}
				$.showAction({
                    title: '添加', 
                    area: '750px', 
                    content: template('tpl-add', result.data), 
                    uCheck: true, 
                    success: function ($content) {
                        $('#my-form').formPost({
                            url: "{:url('applet.code/add')}"
                        });
                    }, 
                    btn2: function ($content) {
                        return true;
                    }
                });
            });
        });
        //编辑
        $('.hema-edit').on('click', function () {
            var data = $(this).data();
            $.get("{:url('applet.code/edit')}?id=" + data.id, function (result) {
				if(result.code == 0){
				    $.show_error(result.msg);
				    return false;
				}
				$.showAction({
                    title: '编辑', 
                    area: '750px', 
                    content: template('tpl-edit', result.data), 
                    uCheck: true, 
                    success: function ($content) {
                        $('#my-form').formPost({
                            url: "{:url('applet.code/edit')}?id=" + data.id
                        });
                    }, 
                    btn2: function ($content) {
                        return true;
                    }
                });
            });
        });
        // 删除元素
        var url = "{:url('applet.code/delete')}";
        $('.hema-del').del('id', url);
    });
</script>

